
package com.cptravel.adapter;

import java.util.List;

import android.app.Activity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.core.controller.B5MBaseAdapter;
import com.core.util.B5MBitmapHelper;
import com.cptravel.R;
import com.cptravel.bean.Product;

public class HotAdapter extends B5MBaseAdapter<Product>
{
    public HotAdapter(Activity activity, List<Product> mList)
    {
        super(activity, mList);
        // TODO Auto-generated constructor stub
    }

    @Override
    public View getView(int position , View convertView , ViewGroup parent , ViewHolder viewHolder)
    {
        // TODO Auto-generated method stub
        ImageView iv_logo = viewHolder.obtainView(convertView, R.id.iv_logo);
        TextView tv_title = viewHolder.obtainView(convertView, R.id.tv_title);
        TextView tv_level_distance = viewHolder.obtainView(convertView, R.id.tv_level_distance);
        TextView tv_price = viewHolder.obtainView(convertView, R.id.tv_price);
        TextView tv_desc = viewHolder.obtainView(convertView, R.id.tv_desc);
        ImageView iv_hot = viewHolder.obtainView(convertView, R.id.iv_hot);
        Product product = list.get(position);
        iv_hot.setVisibility(product.ishot == 0 ? View.GONE : View.VISIBLE);
        B5MBitmapHelper.displayDefaultNotPeopleRoundImage(product.thum_img, iv_logo);
        tv_title.setText(product.title);
        int level = "".equals(product.level) ? 0 : Integer.valueOf(product.level);
        StringBuilder stringBuilder = new StringBuilder();
        for (int i = 0; i < level; i++)
        {
            stringBuilder.append("A");
        }
        tv_level_distance.setText(stringBuilder.toString());
        tv_price.setText(product.lowest_price);
        tv_desc.setText(product.desc);
        return convertView;
    }

    @Override
    public int itemLayoutRes()
    {
        // TODO Auto-generated method stub
        return R.layout.hot_item;
    }
}
